var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, r) {
    var o, a = arguments.length, i = a < 3 ? e : null === r ? r = Object.getOwnPropertyDescriptor(e, n) : r;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, n, r); else for (var c = t.length - 1; 0 <= c; c--) (o = t[c]) && (i = (a < 3 ? o(i) : 3 < a ? o(e, n, i) : o(e, n)) || i);
    return 3 < a && i && Object.defineProperty(e, n, i), i;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("ShopView"), s = e("Global"), c = e("AudioManager"), l = e("GameConfig"), d = e("GameData"), u = e("LoadManager"), p = e("UIManager"), h = e("WebManager"), f = cc._decorator, g = f.ccclass, m = f.property, y = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.bgOne = null, t.bgTwo = null, t.sprite = null, t.nameLabel = null, t.rankLabel = null, 
        t.profitLabel = null, t.priceLabel = null, t.buyBtn = null, t.type = r.ShopItemType.ARM, 
        t.rank = 0, t.price = 0, t;
    }
    return i(t, e), t.prototype.onClickBuy = function() {
        var t, e;
        if (c.default.getInstance().playAudio("按钮2"), h.default.getInstance().sentLog("点击商店界面购买按键"), 
        d.GD.money < this.price) s.G.platform != s.Platform.XiaoDu ? (cc.log("金币不足"), p.default.getInstance().loadPopPnl("money", {
            num: (s.G.getPrice(Math.max(d.GD.topRank - 2, 0)) + 500) * Math.max(1 - l.GC.money_reduce * d.GD.topRank, .001)
        })) : p.default.getInstance().showToast({
            str: "金币不足"
        }); else {
            var n = p.default.getInstance().getPnl("start"), r = n.boxs.filter(function(t) {
                return t.isEmpty();
            });
            if (0 == r.length) return cc.log("栏位已满"), void (null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.showToast) || void 0 === e || e.call(t, {
                title: "栏位已满",
                icon: "none"
            }));
            n.appendItem(this.rank, r[0]) && (c.default.getInstance().playAudio("获得武器"), d.GD.updateNumber("money", -this.price), 
            d.GD.count[this.rank] ? d.GD.count[this.rank]++ : d.GD.count[this.rank] = 1, n.buyItem.refresh(), 
            n.updateMatrix(), this.priceLabel.string = GA.formatNumber(s.G.getPrice(this.rank)), 
            p.default.getInstance().barViews.forEach(function(t) {
                return t.refresh();
            }));
        }
    }, t.prototype.start = function() {}, t.prototype.init = function(t) {
        switch (t.type) {
          case r.ShopItemType.ARM:
            this.initArm(t);
            break;

          case r.ShopItemType.ITEM:
            this.initItem(t);
            break;

          default:
            this.initArm(t);
        }
    }, t.prototype.initArm = function(t) {
        var e = this;
        cc.log("shop item data", t), this.type = r.ShopItemType.ARM, t.name && (this.nameLabel.string = t.name), 
        isNaN(t.rank) || (this.rank = t.rank, this.price = s.G.getPrice(this.rank), this.rankLabel.string = (this.rank + 1).toString(), 
        this.nameLabel.string = s.G.getGunModel(this.rank).m, this.priceLabel.string = GA.formatNumber(this.price), 
        this.profitLabel.string = GA.formatNumber(s.G.getProfit(this.rank)) + "/秒", this.scheduleOnce(function() {
            e.rank > d.GD.topRank ? (e.sprite.node.color = cc.Color.BLACK, e.buyBtn.interactable = !1) : (e.sprite.node.color = cc.Color.WHITE, 
            e.buyBtn.interactable = !0);
        }), u.default.getInstance().loadSpriteFrame({
            url: "image/arm/" + s.G.getIdxByRank(this.rank),
            sprite: this.sprite
        }));
    }, t.prototype.initItem = function() {
        this.type = r.ShopItemType.ITEM;
    }, a([ m(cc.Node) ], t.prototype, "bgOne", void 0), a([ m(cc.Node) ], t.prototype, "bgTwo", void 0), 
    a([ m(cc.Sprite) ], t.prototype, "sprite", void 0), a([ m(cc.Label) ], t.prototype, "nameLabel", void 0), 
    a([ m(cc.Label) ], t.prototype, "rankLabel", void 0), a([ m(cc.Label) ], t.prototype, "profitLabel", void 0), 
    a([ m(cc.Label) ], t.prototype, "priceLabel", void 0), a([ m(cc.Button) ], t.prototype, "buyBtn", void 0), 
    a([ g ], t);
}(cc.Component);

n.default = y;